# Maintainer: Ariadne Conill <ariadne@dereferenced.org>
pkgname=apko
pkgver=0.9.0
pkgrel=5
pkgdesc="declarative APK-based container building tool with support for Sigstore signatures"
url="https://github.com/chainguard-dev/apko"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/chainguard-dev/apko/archive/v$pkgver/apko-$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir build
	go build -o build/ -tags -tags=pivkey,pkcs11key "$builddir"/...

	for i in bash fish zsh; do
		"$builddir"/build/apko completion $i > "$builddir"/apko.$i
	done
}

check() {
	go test "$builddir"/...
}

package() {
	install -Dm755 "$builddir"/build/apko "$pkgdir"/usr/bin/apko

	install -Dm644 "$builddir"/apko.bash "$pkgdir"/usr/share/bash-completion/completions/apko
	install -Dm644 "$builddir"/apko.fish "$pkgdir"/usr/share/fish/vendor_completions.d/apko.fish
	install -Dm644 "$builddir"/apko.zsh "$pkgdir"/usr/share/zsh/site-functions/_apko
}

sha512sums="
c8883955a99811762c3d358549d041c464a1dfe67f24b63666664c72dc2d0bb10b8ff517a8205c14d56a826bd0d02770aa254eefa06c50026e91833319387f24  apko-0.9.0.tar.gz
"
